package com.sl.modulars.trans.equipment.web;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sl.api.base.result.ResultWrapper;
import com.sl.modulars.trans.equipment.entity.*;
import com.sl.modulars.trans.equipment.entity.query.*;
import com.sl.modulars.trans.equipment.entity.vo.*;
import com.sl.modulars.trans.equipment.service.IEquipmentService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/ods/equipment")
public class EquipmentController {


    @Autowired
    private IEquipmentService iEquipmentService;



    @GetMapping("getOdsTreeByType")
    public ResultWrapper<?> getOdsTreeByType(String treeType){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsTreeByType(treeType));
    }



    /**
     * 分页 查询设备清单数据
     * @param odsGmdcMachineQuery
     * @return
     */

    @PostMapping("getGmdcMachinePage")
    public ResultWrapper<?> getOdsGmdcMachinePage(@RequestBody OdsGmdcMachineQuery odsGmdcMachineQuery) {
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMachinePage(odsGmdcMachineQuery));
    }





    /**
     * 从设备状态维度查询对应的数据
     * @param groupId 分组编号可传递或不传递
     * @return
     */
    @GetMapping("getGmdcMachineCount")
    public ResultWrapper<?> getOdsGmdcMachineCount(String groupId){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMachineCount(groupId));
    }




    /**
     * 根据设备资产编号 查询设备运行参数最新的一条数据
     * @param machineNumber
     * @return
     */
    @GetMapping("getGmdcParamMachineByMachineNumber")
    public ResultWrapper<?> getOdsGmdcParamMachineByMachineNumber(String machineNumber){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcParamMachineByMachineNumber(machineNumber));
    }






    /**
     * 根据设备资产编号查询设备详情数据
     * @param machineNumber 设备资产编号
     * @return
     */
    @GetMapping("getGmdcMachineByMachineNumber")
    public ResultWrapper<?> getOdsGmdcMachineByMachineNumber(String machineNumber){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMachineByMachineNumber(machineNumber));
    }


    /**
     * 查询某个设备的设备数据详情
     * @param machineNumber
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("getGmdcParamMachineByMachineNumberAndTime")
    public ResultWrapper<?> getOdsGmdcParamMachineByMachineNumberAndTime(String machineNumber, String startTime, String endTime){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcParamMachineByMachineNumberAndTime(machineNumber,startTime,endTime));
    }


    /**
     * 查询工装信息列表分页数据信息
     * @param odsGmdcToolingThingsQuery
     * @return
     */
    @PostMapping("getGmdcToolingThingPage")
    public ResultWrapper<?> getOdsGmdcToolingThingPage(@RequestBody OdsGmdcToolingThingsQuery odsGmdcToolingThingsQuery){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcToolingThingPage(odsGmdcToolingThingsQuery));
    }


    /**
     * 查询工装信息统计数据
     * @param groupId
     * @return
     */
    @GetMapping("getGmdcToolingThingCount")
    public ResultWrapper<?> getOdsGmdcToolingThingCount(String groupId) {
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcToolingThingCount(groupId));
    }



    /**
     * 查询工刀量具列表数据
     * @param odsGmdcMeasuringToolsQuery
     * @return
     */
    @PostMapping("getGmdcMeasuringToolsPage")
    public ResultWrapper<?> getOdsGmdcMeasuringToolsPage(@RequestBody OdsGmdcMeasuringToolsQuery odsGmdcMeasuringToolsQuery){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMeasuringToolsPage(odsGmdcMeasuringToolsQuery));
    }



    /**
     * 查询工刀量具设备数据
     * @param groupId
     * @return
     */
    @GetMapping("getGmdcMeasuringToolsCount")
    public ResultWrapper<?> getOdsGmdcMeasuringToolsCount(String groupId){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMeasuringToolsCount(groupId));
    }


    /**
     * 查询物料编码列表数据
     * @param odsGmdcMaterialQuery
     * @return
     */
    @PostMapping("getGmdcMaterialPage")
    public  ResultWrapper<?> getOdsGmdcMaterialPage(@RequestBody OdsGmdcMaterialQuery odsGmdcMaterialQuery) {
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMaterialPage(odsGmdcMaterialQuery));
    }

    /**
     * 查询物料总数
     * @param groupId
     * @return
     */
    @GetMapping("getGmdcMaterialCount")
    public ResultWrapper<?> getOdsGmdcMaterialCount(String groupId){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMaterialCount(groupId));
    }


    /**
     * 查询用户列表数据
     * @param odsGmdcPersonnelQuery
     * @return
     */
    @PostMapping("getGmdcPersonnelPage")
    public ResultWrapper<?> getOdsGmdcPersonnelPage(@RequestBody OdsGmdcPersonnelQuery odsGmdcPersonnelQuery){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcPersonnelPage(odsGmdcPersonnelQuery));
    }


    @GetMapping("getOdsTreeByTypeDevice")
    public ResultWrapper<?> getOdsTreeByTypeDevice(String treeType){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsTreeByTypeDevice(treeType));
    }





    /**
     * 查询人员数据统计详情
     * @param groupId
     * @return
     */
    @GetMapping("getGmdcPersonnelCount")
    public ResultWrapper<?> getOdsGmdcPersonnelCount(String groupId){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcPersonnelCount(groupId));
    }



    /**
     * 查询计量设备列表数据
     * @param odsGmdcMeteringEquipmentQuery
     * @return
     */
    @PostMapping("getGmdcMeteringEquipmentPage")
    public ResultWrapper<?> getOdsGmdcMeteringEquipmentPage(@RequestBody OdsGmdcMeteringEquipmentQuery odsGmdcMeteringEquipmentQuery){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMeteringEquipmentPage(odsGmdcMeteringEquipmentQuery));
    }


    /**
     * 查询计量设备 展示维度数据
     * @param groupId
     * @return
     */
    @GetMapping("getOdsGmdcMeteringEquipmentCount")
    public ResultWrapper<?> getOdsGmdcMeteringEquipmentCount(String groupId){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMeteringEquipmentCount(groupId));
    }


    /**
     * 查询测量设备树结构
     * @param treeType
     * @return
     */
    @GetMapping("getTreeByTypeGmdcMetering")
   public ResultWrapper<?> getOdsTreeByTypeGmdcMetering(String treeType){
       return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsTreeByTypeGmdcMetering(treeType));
   }



    /**
     * 查询计量设备采集详情 分页查询
     * @param odsFileGmdcEquipmentGatherQuery
     * @return
     */
    @PostMapping("getFileGmdcEquipmentGather")
    public ResultWrapper<?> getOdsFileGmdcEquipmentGather(@RequestBody OdsFileGmdcEquipmentGatherQuery odsFileGmdcEquipmentGatherQuery){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsFileGmdcEquipmentGather(odsFileGmdcEquipmentGatherQuery));
    }


    /**
     * 查询指标卡 计量设备采集详情
     * @return deviceId
     */
    @GetMapping("getOdsTreeByTypeGmdcMeteringCount")
   public ResultWrapper<?> getOdsTreeByTypeGmdcMeteringCount(String deviceId){
       return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsTreeByTypeGmdcMeteringCount(deviceId));
   }



    /**
     * 查看采集数据详情
     * @param odsFileEquipmenCaptureDetailsQuery
     * @return
     */
    @PostMapping("getOdsFileEquipmenCaptureDetailsByGid")
    public ResultWrapper<?> getOdsFileEquipmenCaptureDetailsByGid(@RequestBody OdsFileEquipmenCaptureDetailsQuery odsFileEquipmenCaptureDetailsQuery){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsFileEquipmenCaptureDetailsByGid(odsFileEquipmenCaptureDetailsQuery));
    }


    /**
     * 查询环境折线图
     * @param strSn
     * @return
     */
    @GetMapping("getDwdEnvironmentDataByEnvironmentByStrSn")
    public ResultWrapper<?> getDwdEnvironmentDataByEnvironmentByStrSn(String strSn){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getDwdEnvironmentDataByEnvironmentByStrSn(strSn));
    }


    /**
     * 查询环境列表数据
     * @param dwdEnvironmentDataQuery
     * @return
     */
    @PostMapping("getDwdEnvironmentDataPage")
    public ResultWrapper<?> getDwdEnvironmentDataPage(@RequestBody DwdEnvironmentDataQuery dwdEnvironmentDataQuery){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getDwdEnvironmentDataPage(dwdEnvironmentDataQuery));
    }





    /**
     * 查询环境 采集数量 异常环境数 查询环境设备总数
     * @param strSn
     * @return
     */
    @GetMapping("getDwdEnvironmentDataByStrSn")
    public ResultWrapper<?> getDwdEnvironmentDataByStrSn(String strSn){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getDwdEnvironmentDataByStrSn(strSn));
    }



    /**
     * 查询环境设备树结构
     * @param treeType
     * @return
     */
    @GetMapping("getTreeByTypeEnvironmentData")
    public ResultWrapper<?> getOdsTreeByTypeEnvironmentData(String treeType){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsTreeByTypeEnvironmentData(treeType));
    }


    @GetMapping("getOdsGmdcMachineByNum")
    public ResultWrapper<?> getOdsGmdcMachineByNum(String machineNumber){
        return ResultWrapper.getSuccessResultWrapper(iEquipmentService.getOdsGmdcMachineByNum(machineNumber));
    }
}
